﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NuMvvm.Services
{
    public class Window : System.Windows.Window, IWindow
    {
        public Window()
        {
            Activated += Window_Activated;
            Deactivated += Window_Deactivated;
        }
  
        public Window(object arg) : this()
        {
            Argument = arg;
        }

        private void Window_Activated(object sender, EventArgs e)
        {
            Current = this;
        }

        private void Window_Deactivated(object sender, EventArgs e)
        {
            Current = null;
        }

        public new void Close()
        {
            base.Close();
        }

        public object Argument { get; private set; }

        public static IWindow Current { get; internal set; }
    }

    public abstract class DialogWindow : System.Windows.Window, IDialogWindow
    {
        public void Close(bool? result)
        {
            DialogResult = result;
        }

        public new void Close()
        {
            DialogResult = null;
            base.Close();
        }
    }
}
